/*
 * OutputReference.java
 *
 * Created on August 5, 2006, 2:22 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.smallx.xproc;

import org.infoset.xml.Name;
import org.infoset.xml.NamespaceScope;
import org.infoset.xml.XMLException;


/**
 *
 * @author alex
 */
public class PortReference extends Reference {

   Name step;
   Name port;
   
   /** Creates a new instance of OutputReference */
   public PortReference(Name step, Name port) {
      this.step = step;
      this.port = port;
   }
   
   public Name getStepName() {
      return step;
   }
   
   public Name getPortName() {
      return port;
   }
   
   public boolean equals(Object obj) {
      if (obj instanceof PortReference) {
         PortReference other = (PortReference)obj;
         return other.getStepName().equals(step) && other.getPortName().equals(port);
      } else {
         return false;
      }
   }
   
   public int hashCode() {
      int hash = 1;
      hash = hash * 31 + step.hashCode();
      hash = hash * 31 + port.hashCode();
      return hash;
   }
   
   /*
   public static PortReference parse(NamespaceScope scope,String expr) 
      throws XMLException
   {
      expr = expr.trim();
      int bang = expr.indexOf('!');
      if (bang<0) {
         throw new XMLException("There is no '!' in the port reference.");
      }
      String stepQName = expr.substring(0,bang);
      if (stepQName.length()==0) {
         throw new XMLException("There is no step name in the port reference.");
      }
      String portQName = expr.substring(bang+1);
      if (portQName.length()==0) {
         throw new XMLException("There is no port name in the port reference.");
      }
      Name step = scope.expandName(stepQName,false);
      Name port = scope.expandName(portQName,false);
      return new PortReference(step,port);
   }
    */
   
}
